/*
 * Fishing.cpp
 *
 *  Created on: 2013. 11. 29.
 *      Author: mega
 */

#include "../User.h"
#include "../NLogic/Function.h"
#include "../NUtil/Utils.h"
#include "../NResource/Static.h"
#include "Fishing.h"

namespace ProjectZ { namespace NLogic {

Fishing::Fishing(User * pUser)
{
	_last_tick	= NLogic::NFunction::GetTickCount();
	_user		= pUser;
}

Fishing::~Fishing()
{

}

void
Fishing::Initialize()
{

}

void
Fishing::Finalize()
{

}

int
Fishing::GetGoldFromFishing()
{
	NResource::BalanceData * pBalance = NResource::Static::InstancePtr()->GetBalance()->GetBalancePtr(_user);
	if (NULL == pBalance)
	{
		PROCESSLOG("%s : pBalance is NULL!!", __FUNCTION__);
		return 0;
	}

	unsigned long cur_tick = NLogic::NFunction::GetTickCount();

	// 3초내에 요청이 중복되는 경우
	if ((cur_tick - _last_tick) < 3 * 1000) {
		return 0;
	}

	_last_tick = cur_tick;

	int min_gold = pBalance->GetValue(EM_FISHING_GOLD_MIN);
	int max_gold = pBalance->GetValue(EM_FISHING_GOLD_MAX);

	return NUtil::GetRandBetween(min_gold, max_gold);
}

} /*NLogic*/ } /* namespace ProjectZ */
